/* eslint-disable react-refresh/only-export-components */

import { useEffect, useState } from "react"
import { useLoaderData } from "react-router-dom"
import { xqApi } from "../../api/user"


function Index() {
const lo= useLoaderData()
const [list,setList]=useState([])
const [id,setid]=useState(lo.res)
// console.log(id);
const getdata=async()=>{
  const xq=await xqApi(id.id)
  console.log(xq)
  setList(xq)
}
useEffect(()=>{
  getdata()
},[])
  return (
    <div>
      {list.content}
    </div>
  )
}

export default Index
export const loader=({request})=>{
  const url=new URL(request.url)
  // console.log(url)
  const obj={...Object.fromEntries(url.searchParams)}
  // console.log(obj)
  return {res:obj}
}